<?php
/**
 * Created by PhpStorm.
 * User: 共赢岛
 * Date: 2023/12/9
 * Time: 17:08
 */

namespace App\Services\LifeCycle;

use App\Models\Store;

class StoreService
{
    public static function all($condition = [])
    {
        return Store::where($condition)->get();
    }

    public static function one($id) {

    }

    public static function storeSelect($brand_id = '')
    {
        $new_store = [];

        if ($brand_id) {
            $where = ['brand_id' => $brand_id];
        } else {
            $where = [];
        }

        $store = self::all($where);

        if ($store) {
            foreach ($store as $key => $value) {
                $new_store[$key]['value'] = $value['id'];
                $new_store[$key]['text'] = $value['title'];
            }
        }

        return $new_store;
    }
}